# file:     yamltunes.rb
# author:   davidfmiller http://www.fivevoltlogic.com/code/mytunes/yaml
# version:  v0.1
# about:    a script that reads data from the command-line and translates it into itunes playlists
# examples: ruby yamltuneimporter.rb playlist.yamltunes
#           cat playlist.yamltunes | ruby yamltuneimporter.rb

require 'yamltunes'
require 'applescript'

# if no files are specified on the command-line then read from stdin
if (ARGV.length == 0) 

	buffer = ''
	STDIN.each_line() do |l|
	 buffer += l
	end

	y = YAMLTunes.new(buffer)
	y.run

# otherwise treat each command-line argument as a file and 
else

	ARGV.each { |a|
		y = YAMLTunes.new(File.open(a))
		y.run
	}

end